from docx import Document

file_path = '序号测试.docx'
d = Document(file_path)
print(d)
numbering_part = d.part.numbering_part
# 获取numbering.xml文件中的信息
ct_numbering = numbering_part.element

num_ids = ct_numbering.xpath('./w:num/@w:numId')

absnum_ids = ct_numbering.xpath('./w:num/w:abstractNumId/@w:val')

abstract_num_dict = dict(zip(num_ids, absnum_ids))

absnums = ct_numbering.xpath('//w:abstractNum/@w:abstractNumId')
fmts = ct_numbering.xpath('//w:abstractNum/w:lvl/w:numFmt/@w:val')
abstract_fmts_dict = dict(zip(absnums, fmts))

print('abstract_num_dict', abstract_num_dict)
print('abstract_fmts_dict', abstract_fmts_dict)
numbering_fmt_dict = {}
for k,v in abstract_num_dict.items():
    numbering_fmt_dict[k] = abstract_fmts_dict[v]
print(numbering_fmt_dict)